<template>
    <div>
        11111
        <button @click="getRecommendPoetry()">发送请求</button>
        <button @click="toHome()">页面跳转</button>
    </div>
</template>

<script>
import { recommendPoetry } from "../api/request.js";
export default {
    methods: {
        getRecommendPoetry() {
            console.log(this.$store.state.token);
            // 调用mutations
            this.$store.commit('setToken',456)
            console.log(this.$store.state.token);
            // 调用actions
            this.$store.dispatch('setToken',789)
            console.log(this.$store.state.token);
            recommendPoetry().then((res) => {
                console.log(res);
            });
        },
        toHome(){
            console.log(this.$route.path)
            this.$router.push({name:'Home',params:{from:this.$route.path}})
        }
    },
};
</script>

<style scoped>
button {
    width: 100px;
    height: 100px;
}
</style>>